package packet1;

import java.util.*;

public class xiec11 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        sc.nextLine();
        for (int i = 0; i < n; i++) {
            String str = sc.nextLine();
            if(Integer.parseInt(str) % 2 == 0){
                System.out.println(str);
                continue;
            }
            int[] flag = new int[10];
            for (int j = 0; j < str.length(); j++) {
                flag[str.charAt(j) - '0']++;
            }
            int t = -1;
            for (int j = 0; j < 10; j += 2) {
                if(flag[j] != 0){
                    t = j;
                    break;
                }
            }
            if(t == -1)
                System.out.println(-1);
            else {
                StringBuilder sb = new StringBuilder();
                for (int j = 1; j < 10 ; j++) {
                    if(j != t){
                        for (int k = 0; k < flag[j]; k++) {
                            sb.append(j);
                        }
                    }
                }
                for (int j = 0; j < flag[t]; j++) {
                    sb.append(t);
                }
                System.out.println(sb.toString());
            }
        }
    }
}
/*
3
13
123
24
 */